-
Notifications
You must be signed in to change notification settings - Fork 5
Fendermint [247, 248, 249]: Checkpoint signatures #202
Conversation
src/gateway/GatewayRouterFacet.sol
Outdated
event SignaturesUpdated(uint256 h, bytes32 pof, Membership membership, bytes signature); | ||
event SignatureInvalid(uint256 h, bytes32 pof, Membership membership, bytes signature); | ||
event PoFThresholdReached(uint256 h, bytes32 pof, Membership membership, uint256 threshold); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are h
and pof
? If h
is block height, shouldn't it be uint64
? Does it cost anything to have longer field names?
A rule of thumb was to make field names which are long lived more verbose, and only use single letters for short-lived local variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for solidity, we have a convention to use U256
for block number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cryptoAtwill but we use uint64 in all mappings mapping block numbers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's the thing. In fvm
, it's either u64
or i64
, but in solidity, it's U256
. How we do this previously is just use U256
in solidity as it's the convention. Then in rust, we convert to whatever is the preferred type. I don't feel we will run into overflow though. But feel free to suggest otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like just a dogmatic choice that is a forever thorn in one's side of how to handle the potential conversion errors, and takes up more space, but if that's how you want it 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but in solidity, it's U256
@cryptoAtwill In the Solidity actors we also use uint64
as far as I see
src/gateway/GatewayRouterFacet.sol
Outdated
|
||
if (signerExists) { | ||
uint256 threshold = s.bottomUpCollectedSignaturesThreshold[h][pof]; | ||
threshold += membership.validators[signerIndex].weight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be written back to the storage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry what was the fix? I'm not a Solidity storage buff; it looks like you can take records and modify them and expect them to be persisted, I'm just checking if that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix is to use "storage" type instead of "memory" type. But it was not fixed actually in that sense. Fixed now. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good now, just minor comments and questions 👍
Great catches! |
src/gateway/GatewayRouterFacet.sol
Outdated
revert CheckpointMembershipNotCreated(); | ||
} | ||
|
||
bytes32 checkpointHash = checkpoint.toHash(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a difference btw checkpointHash
and checkpointInfo.hash
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the checkpoint
is read from storage, that means we can storage the checkpointHash
in storage as well? So that we dont have to compute it every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot checnge that one. Thanks!
uint256 weight, | ||
bytes memory signature | ||
) external { | ||
BottomUpCheckpointNew memory checkpoint = s.bottomUpCheckpoints[height]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we do backward check? Like the height should not have already committed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current idea is to continue to allow accumulating signatures even if it has been committed. In this case, we update signatures and emit an event with updated weight. If I understood you right...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bullseye 🎯
@@ -21,6 +21,39 @@ struct BottomUpCheckpoint { | |||
bytes proof; | |||
} | |||
|
|||
/// @notice A bottom-up checkpoint type. | |||
// TODO: Remove old BottomUpCheckpoint, rename BottomUpCheckpointNew to BottomUpCheckpoint and update the codebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnkolegov, @cryptoAtwill, are we tracking this TODO somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -50,8 +50,9 @@ contract GatewayGetterFacet { | |||
return s.networkName; | |||
} | |||
|
|||
// TODO: remove or add a new getter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnkolegov, should we track this in an issue like the others TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR addresses